import Mock from "mockjs";
import documentEntity from "../model/document.entity"


const documentInstance = new documentEntity();

// 用户协议信息
Mock.mock(
  RegExp("/mock/api/document/regagreement_info" + ".*"),
  "get",
  () => {
    return {
      code: 200,
      msg: "success",
      data: documentInstance.findAll(),
    };
  }
);

// 用户协议编辑
Mock.mock(
  RegExp("/mock/api/document/regagreement_conf" + ".*"),
  "post",
  (request: any) => {
    let res = JSON.parse(request.body);
    let data:any = {};
    Object.entries(res).forEach((item:any[]) => {
      data[item[0]] = documentInstance.updateOne(item[0], item[1]);
    })
    return {
      code: 200,
      msg: "success",
      data,
    };
  }
);